﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.ObjectModel;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for DatabaseQueryTest and is intended
    ///to contain all DatabaseQueryTest Unit Tests
    ///</summary>
    [TestClass()]
    public class DatabaseQueryTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ChangeStatus
        ///</summary>

        /// <summary>
        ///A test for ChangeStatusUser
        ///</summary>
        [TestMethod()]
        public void ChangeStatusUserTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string userName = "Luchito"; // TODO: Initialize to an appropriate value
            int newStatus = 1; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.ChangeStatusUser(userName, newStatus);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///Una prueba de GetAmountByUserName
        ///</summary>
        [TestMethod()]
        public void GetAmountByUserNameTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string name = "Gloria"; // TODO: Inicializar en un valor adecuado
            float expected = 5000; // TODO: Inicializar en un valor adecuado
            float actual;
            actual = target.GetAmountByUserName(name);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetChips
        ///</summary>
        [TestMethod()]
        public void GetChipsTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Roberto"; // TODO: Initialize to an appropriate value
            long expected = 20000; // TODO: Initialize to an appropriate value
            long actual;
            actual = target.GetChips(name);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetStatus
        ///</summary>
        [TestMethod()]
        public void GetStatusTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string userName = "Roberto"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.GetStatus(userName);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///Una prueba de GetUserTwo
        ///</summary>
        [TestMethod()]
        public void GetUserTwoTest()
        {
            User user = new User();
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string userName = "Robertoysa"; // TODO: Inicializar en un valor adecuado
            string password = "aurora2yy"; // TODO: Inicializar en un valor adecuado
            User expected = null; // TODO: Inicializar en un valor adecuado
            User actual;
            actual = target.GetUserTwo(userName, password);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetAllUsers
        ///</summary>
        [TestMethod()]
        public void GetAllUsersTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            Collection<User> actual;
            actual = target.GetAllUsers;            
        }




        /// <summary>
        ///A test for BanUser
        ///</summary>
        [TestMethod()]
        public void BanUserTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Gloria"; // TODO: Initialize to an appropriate value
            string ban = "True"; // TODO: Initialize to an appropriate value
            DateTime time = DateTime.Now.AddMinutes(30); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.BanUser(name, ban, time);
            Assert.AreEqual(expected, actual);
         }

        /// <summary>
        ///A test for IBanned
        ///</summary>
        [TestMethod()]
        public void IBannedTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Gloria"; // TODO: Initialize to an appropriate value
            DateTime actual = DateTime.Now; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual1;
            actual1 = target.IBanned(name);
            Assert.AreEqual(expected, actual1);
           
        }

        /// <summary>
        ///A test for IBanned
        ///</summary>
        [TestMethod()]
        public void IBannedTest1()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Roberto"; // TODO: Initialize to an appropriate value
            DateTime actual = DateTime.Now; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual1;
            actual1 = target.IBanned(name);
            Assert.AreEqual(expected, actual1);

        }

        /// <summary>
        ///A test for GetLogUser
        ///</summary>
        [TestMethod()]
        public void GetLogUserTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            Collection<User> actual;
            actual = target.GetLogUser;
            Assert.AreNotEqual(null, actual);
           
        }

        /// <summary>
        ///A test for GetAllLevels
        ///</summary>
        [TestMethod()]
        public void GetAllLevelsTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            LevelDatabase level2 = new LevelDatabase();
            LevelDatabase level3 = new LevelDatabase();
            LevelDatabase level4 = new LevelDatabase();
            LevelDatabase level5 = new LevelDatabase();
            LevelDatabase level6 = new LevelDatabase();

            level2.Chips = 30000;
            level3.Chips = 40000;
            level4.Chips = 60000;
            level5.Chips = 80000;
            level6.Chips = 120000;
            level2.Level = 2;
            level3.Level = 3;
            level4.Level = 4;
            level5.Level = 5;
            level6.Level = 6;
            level2.TimeWon = 10;
            level3.TimeWon = 22;
            level4.TimeWon = 35;
            level5.TimeWon = 60;
            level6.TimeWon = 100;
            Collection<LevelDatabase> actual;
            actual = target.GetAllLevels;
            Collection<LevelDatabase> expected = new Collection<LevelDatabase>();
            expected.Add(level2);
            expected.Add(level3);
            expected.Add(level4);
            expected.Add(level5);
            expected.Add(level6);
            Assert.AreEqual(actual.Count, expected.Count);
        }

        /// <summary>
        ///A test for GetUserTwo
        ///</summary>
        [TestMethod()]
        public void GetUserTwoTest1()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string userName = "Miguel"; // TODO: Initialize to an appropriate value
            string password = "aurora1"; // TODO: Initialize to an appropriate value
            User expected = null; // TODO: Initialize to an appropriate value
            User actual;
            actual = target.GetUserTwo(userName, Convert.ToString(password.GetHashCode()));
            Assert.AreNotEqual(expected, actual);
           
        }

        /// <summary>
        ///A test for IncrementLog
        ///</summary>
        [TestMethod()]
        public void IncrementLogTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string userReceived = "Roberto"; // TODO: Initialize to an appropriate value
            target.IncrementLog(userReceived);
        }

        /// <summary>
        ///A test for GetAllBannedUsers
        ///</summary>
        [TestMethod()]
        public void GetAllBannedUsersTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            Collection<User> actual;
            actual = target.GetAllBannedUsers;
            Assert.AreNotEqual(null,actual);
        }

        /// <summary>
        ///A test for SetLevelTimeWon
        ///</summary>
        [TestMethod()]
        public void SetLevelTimeWonTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Gloria"; // TODO: Initialize to an appropriate value
            int level = 1; // TODO: Initialize to an appropriate value
            long timeWon = 5; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.SetLevelTimeWon(name, level, timeWon);
            Assert.AreEqual(expected, actual);
           
        }

        /// <summary>
        ///A test for RemoveDeck
        ///</summary>
        [TestMethod()]
        public void RemoveDeckTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "paraborrar"; // TODO: Initialize to an appropriate value
            int newDeck = 1; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.RemoveDeck(name, newDeck);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for SetDeck
        ///</summary>
        [TestMethod()]
        public void SetDeckTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "gloria"; // TODO: Initialize to an appropriate value
            int newDeck = 1; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.SetDeck(name, newDeck);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }


        /// <summary>
        ///A test for GetDeck
        ///</summary>
        [TestMethod()]
        public void GetDeckTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Roberto"; // TODO: Initialize to an appropriate value
            string expected = "1 2"; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.GetDeck(name);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///Una prueba de GetAllHands
        ///</summary>
        [TestMethod()]
        public void GetAllHandsTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            Collection<User> actual;
            actual = target.GetAllHands;
            Assert.AreNotEqual(null, actual);
        }

        /// <summary>
        ///Una prueba de NewHand
        ///</summary>
        [TestMethod()]
        public void NewHandTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string name = "Roberto"; // TODO: Inicializar en un valor adecuado
            long amount = 1300; // TODO: Inicializar en un valor adecuado
            string expected = "01"; // TODO: Inicializar en un valor adecuado
            string actual;
            actual = target.NewHand(name, amount);
            Assert.AreEqual(expected, actual);
            
        }

        /// <summary>
        ///Una prueba de BestHand
        ///</summary>
        [TestMethod()]
        public void BestHandTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string name = "Miguel"; // TODO: Inicializar en un valor adecuado
            long expected = 3000; // TODO: Inicializar en un valor adecuado
            long actual;
            actual = target.BestHand(name);
            Assert.AreEqual(expected, actual);
           
        }

        /// <summary>
        ///Una prueba de SetGameStatus
        ///</summary>
        [TestMethod()]
        public void SetGameStatusTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string name = "Roberto"; // TODO: Inicializar en un valor adecuado
            string game = "Wheel"; // TODO: Inicializar en un valor adecuado
            string time = DateTime.Now.ToString(); // TODO: Inicializar en un valor adecuado
            target.SetGameStatus(name, game, time);
            
        }

        /// <summary>
        ///Una prueba de GetUserContacts
        ///</summary>
        [TestMethod()]
        public void GetUserContactsTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string userName = "Roberto"; // TODO: Inicializar en un valor adecuado
            Collection<UserContacts> expected = null; // TODO: Inicializar en un valor adecuado
            Collection<UserContacts> actual;
            actual = target.GetUserContacts(userName);
            Assert.AreNotEqual(expected, actual);
        }

        /// <summary>
        ///Una prueba de Subtract
        ///</summary>
        [TestMethod()]
        public void SubtractTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Inicializar en un valor adecuado
            string amount = "500"; // TODO: Inicializar en un valor adecuado
            string cardNum = "2"; // TODO: Inicializar en un valor adecuado
            string name = "Gloria"; // TODO: Inicializar en un valor adecuado
            int expected = 3; // TODO: Inicializar en un valor adecuado
            int actual;
            actual = target.Subtract(amount, cardNum, name);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ActualHour
        ///</summary>
        [TestMethod()]
        public void ActualHourTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Baneado"; // TODO: Initialize to an appropriate value
            DateTime expected = DateTime.Now; // TODO: Initialize to an appropriate value
            DateTime actual;
            actual = target.ActualHour(name);
            Assert.AreNotEqual(expected, actual);
        }

        /// <summary>
        ///A test for LoanDelete
        ///</summary>
        [TestMethod()]
        public void LoanDeleteTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "paraEliminar"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.LoanDelete(name);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for LoanSetUser
        ///</summary>
        [TestMethod()]
        public void LoanSetUserTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "nuevo"; // TODO: Initialize to an appropriate value
            string loan = "123"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.LoanSetUser(name, loan);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for LoanStatusUser
        ///</summary>
        [TestMethod()]
        public void LoanStatusUserTest()
        {
            DatabaseQuery target = new DatabaseQuery(); // TODO: Initialize to an appropriate value
            string name = "Gloria"; // TODO: Initialize to an appropriate value
            string expected = "123"; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.LoanStatusUser(name);
            Assert.AreEqual(expected, actual);
       }
    }
}
